package com.creative.accountsdk;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.badlogic.gdx.Gdx;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Locale;


public class AccountAgreementActivity extends ThirdLoginActivity {


    private ImageView btnCancel;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        //设置无标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //设置全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

    /*    int orientation = AccountSdk.getInstance().getOrientation();
        if(orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
        {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
        else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }*/
        setContentView(R.layout.activity_account_agreement);

        btnCancel = (ImageView)findViewById(R.id.bn_set_cancel);
        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AccountAgreementActivity.this.finish();
            }
        });

//        Gdx.init(this);
//        String license = Gdx.files.internal("license_test.mht").readString("gb2312");
//        Log.d(getClass().getSimpleName(), license);
//
//        WebView webView1 = (WebView)findViewById(R.id.webView1);
//        webView1.loadData(license, "text/html", "gb2312");
        WebView webView1 = (WebView)findViewById(R.id.webView1);
        /*
        String url;
        if(isZh(this)){
            url = USE_CN_URL;
        }else {
            url = USE_URL;
        }
        webView1.loadUrl(url);
        */
        webView1.loadUrl(getResources().getString(R.string.license_url));
    }


    private boolean isZh(Context context) {
        Locale locale = context.getResources().getConfiguration().locale;
        String language = locale.getLanguage();
        if (language.endsWith("zh"))
            return true;
        else
            return false;
    }
}
